home *** CD-ROM | disk | FTP | other *** search
- #include "appGlobals.h"
- #include "appMenus.h"
- #include "appErrors.h"
-
- #include "win.h"
- #include "winTables.h"
-
- #include "winPictDoc.h"
- #include "winAbout.h"
- #include "winProfile.h"
- #include "winProfileGetSet.h"
- #include "winProfList.h"
- #include "winProfListGetSet.h"
- #include "winProfID.h"
- #include "winProfIDGetSet.h"
-
-
- /**\
- |**| ==============================================================================
- |**| PRIVATE FUNCTION PROTOTYPES
- |**| ==============================================================================
- \**/
- void winUpdateMenusDefault ( winHandle win ) ;
- void winMenuDefault ( winHandle win, long menuResult, Boolean *didit ) ;
- void DoNewCommand ( void ) ;
- void DoAboutBoxCommand ( void ) ;
- void DoDefaultProfCommand ( void ) ;
- void DoProfListCommand ( OSType profileClass ) ;
-
-
- /**\
- |**| ==============================================================================
- |**| PUBLIC GLOBALS
- |**| ==============================================================================
- \**/
- short gAllocProcMapCount = 3 ;
- AllocProcMapRec gAllocProcMap[3] = {
- { 'PICT', winAllocPictDoc, kProfDocPictSubtype, true, false },
- { 'prof', winAllocProfile, kFileSubType, false, false },
- { 'pfid', winAllocProfID, kFileSubType, false, false }
- };
- UpdateMenusProcPtr gDefaulltUpdateMenusProc = winUpdateMenusDefault ;
- MenuProcPtr gDefaulltMenuProc = winMenuDefault ;
-
-
- /**\
- |**| ==============================================================================
- |**| PRIVATE FUNCTIONS
- |**| ==============================================================================
- \**/
-
-
- /*------------------------------------------------------------------------------*\
- winUpdateMenusDefault
- *------------------------------------------------------------------------------*
- This routine enables any menus and menu items in the menu bar
- which the application is responsible for handling.
- It is called by:
- InitMenuBar() which is called when the app is intited,
- DoActivateEvent() which is called whenever a window is brought to front, and
- CloseProcPtrs which are called whenever windows are closed
- \*------------------------------------------------------------------------------*/
- static void winUpdateMenusDefault ( winHandle win )
- {
- MenuHandle theMenu ;
-
- // do the file menu
- theMenu = GetMenuHandle ( mApple ) ;
- EnableItem ( theMenu, kWholeMenu ) ;
- EnableItem ( theMenu, iAbout ) ;
-
- // do the file menu
- theMenu = GetMenuHandle ( mFile ) ;
- EnableItem ( theMenu, kWholeMenu ) ;
- EnableItem ( theMenu, iNew ) ;
-
- // do the profiles menu
- theMenu = GetMenuHandle ( mProfiles ) ;
- EnableItem ( theMenu, kWholeMenu ) ;
- EnableItem ( theMenu, iDefaultProf ) ;
- EnableItem ( theMenu, iCSFolderPopup ) ;
-
- // do the profile lists menu
- theMenu = GetMenuHandle ( mProfileLists ) ;
- EnableItem ( theMenu, kWholeMenu ) ;
- EnableItem ( theMenu, iCSFolder ) ;
- EnableItem ( theMenu, iCSFolderMntr ) ;
- EnableItem ( theMenu, iCSFolderPrtr ) ;
- EnableItem ( theMenu, iCSFolderScnr ) ;
- }
-
-
- /*------------------------------------------------------------------------------*\
- winMenuDefault
- *------------------------------------------------------------------------------*
- This is a MenuProcPtr for the About window.
- This routine dispatches any menu commands that the window can handle
- to the appropriate function.
- For the About window, the only need menu command is File:Close
- This ProcPtr is envoked by CallWinMenuProc() which is called by:
- HandleMenuCommand() which dispatches all menu events.
- \*------------------------------------------------------------------------------*/
- static void winMenuDefault ( winHandle win, long menuResult, Boolean *didit )
- {
- short menuID;
- short menuItem;
-
- *didit = true ;
- menuID = HiWrd(menuResult) ;
- menuItem = LoWrd(menuResult) ;
- switch ( menuID )
- {
- case mApple:
- switch ( menuItem )
- {
- case iAbout:
- DoAboutBoxCommand() ;
- break;
- default :
- *didit = false ;
- break ;
- }
- break;
-
- case mFile:
- switch ( menuItem )
- {
- case iNew: // make a new document
- DoNewCommand() ;
- break;
-
- default :
- *didit = false ;
- break ;
- }
- break;
-
- case mProfiles:
- switch ( menuItem )
- {
- case iDefaultProf:
- DoDefaultProfCommand() ;
- break;
- default :
- *didit = false ;
- break ;
- }
- break;
-
- case mProfileLists:
- switch ( menuItem )
- {
- case iCSFolder:
- DoProfListCommand( 0 ) ;
- break;
- case iCSFolderMntr:
- DoProfListCommand(cmDisplayClass) ;
- break;
- case iCSFolderPrtr:
- DoProfListCommand(cmOutputClass) ;
- break;
- case iCSFolderScnr:
- DoProfListCommand(cmInputClass) ;
- break;
- case iCSFolderName:
- DoProfListCommand(cmNamedColorClass) ;
- break;
- default :
- *didit = false ;
- break ;
- }
- break;
-
- default :
- *didit = false ;
- break ;
- }
- HiliteMenu(0) ; // Unhighlight whatever MenuSelect or MenuKey hilited
- }
-
-
-
- /*------------------------------------------------------------------------------*\
- DoNewCommand
- *------------------------------------------------------------------------------*
- This routine handles the File:New command for the application.
- It is not yet implimented but in principle, it should create a new
- winHandle, and call its OpenProcPtr got get it going.
- It is called by:
- HandleMenuCommand() which dispatches all menu events.
- \*------------------------------------------------------------------------------*/
- static void DoNewCommand ( void )
- {
- OSErr err = noErr ;
- winHandle win;
-
- // create a new winHandle of the propper type
- err = NewWinHandle( &win, winAllocPictDoc ) ;
- WarnIfErr( err ) ;
- if (err) return ;
-
- err = CallWinNewProc( win ) ;
- if ( err != noErr )
- DisposeWinHandle( win ) ;
-
- if ( err == kWasAlreadyOpen )
- err = noErr ;
- }
-
-
- /*------------------------------------------------------------------------------*\
- DoAboutBoxCommand
- *------------------------------------------------------------------------------*
- This routine handles the Apple:About command for the application.
- It creates a new winHandle, sets its NewProcPtr, and then
- calls the NewProcPtr to get it going.
- It is called by:
- HandleMenuCommand() which handles all menu events.
- \*------------------------------------------------------------------------------*/
- static void DoAboutBoxCommand ( void )
- {
- OSErr err = noErr ;
- winHandle win;
-
- // create a new winHandle of the propper type
- err = NewWinHandle( &win, winAllocAbout ) ;
- WarnIfErr( err ) ;
- if (err) return ;
-
- err = CallWinNewProc( win ) ;
- if ( err != noErr )
- DisposeWinHandle( win ) ;
-
- if ( err == kWasAlreadyOpen )
- err = noErr ;
- }
-
-
- /*------------------------------------------------------------------------------*\
- DoDefaultProfCommand
- *------------------------------------------------------------------------------*
- This routine handles the Profile:Default Profile command for the application.
- It creates a new winHandle, sets its OpenProcPtr, and then
- calls the OpenProcPtr to get it going.
- It is called by:
- HandleMenuCommand() which handles all menu events.
- \*------------------------------------------------------------------------------*/
- static void DoDefaultProfCommand ( void )
- {
- OSErr err = noErr ;
- winHandle win;
-
- // create a new winHandle of the proper type
- err = NewWinHandle( &win, winAllocProfile ) ;
- WarnIfErr( err ) ;
- if (err) return ;
-
- SetProfileRef( win, nil ) ;
- SetWinSubtype( win, kSysProfSubType ) ; // set subtype
-
- err = CallWinOpenProc( win ) ;
- if ( err != noErr ) //if an error occured
- DisposeWinHandle( win ) ;
-
- if ( err == kWasAlreadyOpen )
- err = noErr;
- }
-
-
- /*------------------------------------------------------------------------------*\
- DoProfListCommand
- *------------------------------------------------------------------------------*
- This routine handles the Profile:CS Folder command for the application.
- It creates a new winHandle, sets its OpenProcPtr, and then
- calls the OpenProcPtr to get it going.
- It is called by:
- HandleMenuCommand() which handles all menu events.
- \*------------------------------------------------------------------------------*/
- static void DoProfListCommand ( OSType profileClass )
- {
- OSErr err = noErr ;
- winHandle win;
-
- // create a new winHandle of the proper type
- err = NewWinHandle( &win, winAllocProfList ) ;
- WarnIfErr( err ) ;
- if (err) return ;
-
- // set the subtype of the winHandle so that the correct search is done
- SetWinSubtype( win, profileClass ) ; // set subtype
-
- err = CallWinNewProc( win ) ;
- if ( err != noErr )
- DisposeWinHandle( win ) ;
-
- if ( err == kWasAlreadyOpen )
- err = noErr;
- }
-
-
-